﻿using System.Collections.Generic;
using System.Linq;

namespace Inovout.Cloud.Identity
{
    public class IdentirySettings
    {
        public const string DefaultScope = "http://identity.kuajing.com.cn/v1/me";
        private readonly Dictionary<string, string> items;
        public static readonly string TitleKey = "Title";
        public static readonly string SiteUrlKey = "SiteUrl";
        public static readonly string SignInHtmlKey = "SignInHtml";
        public KeyValuePair<string, string> TitleItem
        {
            get { return items.Single(kv => kv.Key.Equals(TitleKey)); }
        }
        public KeyValuePair<string, string> SiteUrlItem
        {
            get { return items.Single(kv => kv.Key.Equals(SiteUrlKey)); }
        }
        public KeyValuePair<string, string> SignInHtmlItem
        {
            get { return items.Single(kv => kv.Key.Equals(SignInHtmlKey)); }
        }
        public IdentirySettings()
            :this(new Dictionary<string,string>())
        {
        }
        private Dictionary<string, string> CreateItems()
        {
            return new Dictionary<string, string>{
             {TitleKey,string.Empty},
             {SiteUrlKey,string.Empty},
             {SignInHtmlKey,string.Empty}
            };
        }
        public IdentirySettings(IDictionary<string, string> dictionary)
        {
            items = CreateItems();
            foreach (var kv in dictionary)
            {
                items[kv.Key] = kv.Value;
            }
        }
    }
}
